package com.gt.controller.user;

import com.gt.pojo.PageResult;
import com.gt.pojo.Result;
import com.gt.pojo.dto.BookDTO;
import com.gt.pojo.dto.BookPageQueryDTO;
import com.gt.service.BookService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController(value = "userBookController")
@Api(tags = "图书相关接口")
@RequestMapping("/user/book")
public class BookController {

    @Autowired
    private BookService bookService;

    @GetMapping("/page")
    @ApiOperation("书籍分页查询")
    public Result<PageResult> pageQuery(BookPageQueryDTO bookPageQueryDTO){
        PageResult pageResult = bookService.pageQuery(bookPageQueryDTO);
        return Result.success(pageResult);
    }
    @ApiOperation("借阅书籍")
    @PutMapping("/{bookId}")
    public Result<String> borrow(@PathVariable("bookId")  Long id){
        bookService.updateByNumber(id);
        return Result.success();
    }
}
